import sun.reflect.generics.tree.Tree;

import java.util.Arrays;
import java.util.TreeSet;

/**
 * @Description
 * @Author zhaobaolin
 * @Date 2018/10/24
 */
public class TreeSetTest {

    public static void main(String[] args) {
        handle();
    }

    private static void create()
    {
        TreeSet<Integer> a1 = new TreeSet<>();
        TreeSet<Integer> a2 = new TreeSet<>(Arrays.asList(2,5,6));
    }

    private static void handle()
    {
        TreeSet<Integer> a1 = new TreeSet<>();
        a1.add(22);
        a1.add(53);
        a1.add(66);
        a1.add(9);
        a1.add(12);
        a1.add(27);
        a1.add(19);
        a1.add(35);
        System.out.println(a1);//output：[9, 12, 19, 22, 27, 35, 53, 66]

        TreeSet<Integer> a2 = new TreeSet<>(a1.subSet(10,30));//获取a1中10到30的元素 组成新树
        System.out.println(a2);//[12, 19, 22, 27]

    }
}
